package com.forenow.demo.Book;

public class MainStu {
    public Student[] GradeOrder(Student[] a){
        for (int i=0;i<a.length;i++){
            for (int j=0;j<a.length-i-1;j++){
                if (a[j].getGrade()<a[j+1].getGrade()){
                    Student temp=a[j+1];
                    a[j+1]=a[j];
                    a[j]=temp;
                }
            }

        }
        return a;
    }
    public static void main(String[] args) {
            MainStu mainStu=new MainStu();
            Student stu1=new Student("cindy",1001,98);
            Student stu2=new Student("tom",1002,75);
            Student stu3=new Student("Bob",1003,89);
            Student[] arr=new Student[3];
            arr[0]=stu1;
            arr[1]=stu2;
            arr[2]=stu3;
            Student[] stu=new Student[arr.length];
            stu=mainStu.GradeOrder(arr);
        for (Student s:stu
             ) {
            System.out.println(s.getName()+"--"+s.getId()+"--"+s.getGrade());
        }
    }
}
